package com.mm.cme.kotlin_001.level03_object_oriented_program.data_class

import com.mm.cme.kotlin_001.level03_object_oriented_program.data_class.annotation.Poko
import com.mm.cme.kotlin_001.utils.pd
import com.mm.cme.kotlin_001.utils.pl

/**
 * Descriptions：数据类，Java中的JavaBean
 * <p>
 * Author：ChenME
 * Date：2017/7/23
 * Email：ibelieve1210@163.com
 */

@Poko
data class Country(val id: Int, val name: String)

class ComponentX {

    operator fun component1(): String {
        return "您好！我是"
    }

    operator fun component2(): Int {
        return 1
    }

    operator fun component3(): Int {
        return 1
    }

    operator fun component4(): Int {
        return 0
    }
}

fun main(args: Array<String>) {
    val china = Country(0, "中国")
    pl(china)
    pl(china.component1())
    pl(china.component2())
    val (id, name) = china
    pl("$id -> $name")

    pd()
    val (a, b, c, d) = ComponentX()
    pl("$a $b$c$d")
}